//引入路由、路由模式
import { createRouter, createWebHashHistory } from "vue-router";
//1.声明routes配置，一个routes是一个数组，routes对象里面的基本属性由path和component组成
let routes = [
  {
    path: "/",
    //具名路由
    name: "/",
    //路由元信息
    meta: {
      //meta中的属性随便添加
      name: "导航首页",
    },
    component: () => import("../pages/home/index.vue"),
    children: [
      {
        path: "discover",
        name: "discover",
        redirect: "/discover/playlist",
        meta: {
          name: "发现",
        },
        component: () => import("../pages/discover/index.vue"),
        children: [
          {
            path: "playlist",
            name: "playlist",
            meta: {
              name: "歌单",
            },
            component: () => import("../pages/discover/playlist/index.vue"),
          },
        ],
      },
      {
        path: "my",
        name: "my",
        meta: {
          name: "个人中心",
        },
        component: () => import("../pages/my/index.vue"),
      },
      {
        props: true,
        path: "friend/:id",
        name: "friend/:id",
        meta: {
          name: "朋友",
        },
        component: () => import("../pages/friend/index.vue"),
      },
    ],
  },
  {
    path: "/login",
    name: "/login",
    meta: {
      name: "登入页",
    },
    component: () => import("../pages/login/index.vue"),
  },
];
//2.创建路由
const router = createRouter({
  history: createWebHashHistory("/base"), //可以传基础路径
  routes,
});
//3.导出路由
export default router;
